<h1>Зургийн цомог</h1>

<?php echo link_to('жагсаалт', 'gallery/index', array('class'=>'title'))?> 
<span class="separator"> | </span>
<?php echo link_to('шинээр нэмэх', 'gallery/new', array('class'=>'title'))?>
<br clear="all">
<br clear="all">

<form action="<?php echo url_for('gallery/index')?>" method="GET">
  <b>Хайх үг:</b>&nbsp;
  <input id="keyword" name="keyword" value="<?php echo $sf_request->getParameter('keyword')?>" style="width:400px;"/>
  <input type="submit" value="Submit" style="cursor:pointer;font-weight:bold;" />
</form>

<br clear="all">

<?php foreach ($pager->getResults() as $album): ?>
  <div style="position:relative;width:124px;height:150px;overflow:hidden;padding:2px;float:left;margin:5px;border:1px solid #ccc;">
    <a href="<?php echo url_for('gallery/images?albumId='.$album->getId())?>">
        <?php echo image_tag('/uploads/gallery/'.$album->getCoverImage(), array('alt'=>$album, 'title'=>$album, 'style'=>'float:left; max-width:120px; max-height:120px;'))?>
        <?php echo $album?>
    </a>
    <a style="position:absolute;bottom:0px;right:36px;" href="<?php echo url_for('gallery/newImage?albumId='.$album->getId()) ?>"><?php echo image_tag('icons/photo-icone-4446-16.png', array())?></a>
    <a style="position:absolute;bottom:-1px;right:12px;" href="<?php echo url_for('gallery/edit?id='.$album->getId()) ?>"><?php echo image_tag('icons/edit.gif', array())?></a>
    <a style="position:absolute;bottom:0px;right:0px;" onclick="return confirm('Та итгэлтэй байна уу?')" href="<?php echo url_for('gallery/delete?id='.$album->getId()) ?>"><?php echo image_tag('icons/delete.gif', array())?></a>
  </div>
<?php endforeach; ?>


<?php echo pager($pager, 'gallery/index')?>

<script type="text/javascript">

function loadObjects()
{
  $.ajax({
      url: "<?php echo url_for('gallery/loadObjects')?>",
      data: {objectType : $('#objectType').val(), objectId: <?php echo $sf_request->getParameter('objectId') ? $sf_request->getParameter('objectId') : 0?>},
      type: "POST",
      success: function(data){
          $('#container_object_id').html('<select id="objectId" name="objectId" style="width:400px;">' + data + '</select>');
      }
  });
  return false;
}

$(document).ready(function() {
  loadObjects();  
});
</script>